from web.template import CompiledTemplate, ForLoop, TemplateResult

_dummy = CompiledTemplate(lambda: None, 'dummy')
join_ = _dummy._join
escape_ = _dummy._escape

def index():
    __lineoffset__ = -4
    loop = ForLoop()
    self = TemplateResult(); extend_ = self.extend
    extend_([u'<html>\n'])
    extend_([u'    <head>\n'])
    extend_([u'        <title>douban library</title>\n'])
    extend_([u'        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \n'])
    extend_([u'    <meta http-equiv="Pragma" content="no-cache" /> \n'])
    extend_([u'    <meta content="\u901a\u8fc7douban api\u68c0\u7d22\u56fe\u4e66\u9986\u56fe\u4e66" name="description"/> \n'])
    extend_([u'\n'])
    extend_([u'    </head>\n'])
    extend_([u'    <body>\n'])
    extend_([u'       \u611f\u8c22\u60a8\u7684\u5149\u4e34douban library\uff0c\u8fd9\u662f\u4e00\u4e2a\u5229\u7528<a href="http://www.douban.com/service/">douban API</a>\u68c0\u7d22\u56fe\u4e66\u9986\u8d44\u6e90\u7684\u5e94\u7528;\n'])
    extend_([u'<br>\u4f1a\u81ea\u52a8\u6839\u636e\u60a8\u63d0\u4f9b\u7684<a href="http://www.douban.com/mine/">\u8c46\u74e3id</a>\u7684<a href="http://book.douban.com/mine?status=wish">\u60f3\u8bfb</a>\u4fe1\u606f\u68c0\u7d22\u56fe\u4e66\u9986\u6761\u76ee;<br>\u6682\u65f6\u53ea\u5b9e\u73b0\u4e86\u9996\u90fd\u56fe\u4e66\u9986\u3002\n'])
    extend_([u'    <p>\n'])
    extend_([u'    <hr>\n'])
    extend_([u'    \u4f7f\u7528\u65b9\u6cd5\uff0c\u4e0b\u65b9\u8f93\u5165\u60a8\u7684\u8c46\u74e3id\n'])
    extend_([u'        <form action="/view" method="get" name="user">\n'])
    extend_([u'        <label for="username">username</label></th><td><input type="text" id="username" name="username"/><div class="get" style="display: none;"></div>\n'])
    extend_([u'        <input type="submit" value="\u641c\u7d22" class="bn-srh">\n'])
    extend_([u'        </form>\n'])
    extend_([u'    </p> \n'])
    extend_([u'    <br>\n'])
    extend_([u'    <img src="http://msl.appspot.com/static/images/gmail.png">\n'])
    extend_([u'    </body>\n'])
    extend_([u'</html>\n'])

    return self

index = CompiledTemplate(index, 'templates/index.html')

def view (tables):
    __lineoffset__ = -3
    loop = ForLoop()
    self = TemplateResult(); extend_ = self.extend
    extend_([u'<html>\n'])
    extend_([u'    <head>\n'])
    extend_([u'        <title>D-lib</title>\n'])
    extend_([u'        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \n'])
    extend_([u'    <meta http-equiv="Pragma" content="no-cache" /> \n'])
    extend_([u'    </head>\n'])
    extend_([u'    <body>\n'])
    extend_([u'        <table>\n'])
    for td in loop.setup(tables):
        extend_(['            ', u'<tr>\n'])
        for t in loop.setup(td):
            extend_(['                ', escape_(t, False), u'\n'])
        extend_(['            ', u'</tr>\n'])
    extend_([u'        </table>\n'])
    extend_([u'    </body>\n'])
    extend_([u'</html>\n'])

    return self

view = CompiledTemplate(view, 'templates/view.html')

